extends VBoxContainer


func init():
	Global.clearChildNode(self)
	
	createUIHeadIcon(GlobalData.playerData)
	
	for partnerData in GlobalData.partnersData:
		var inst = createUIHeadIcon(partnerData)
		
		
func select(data):
	for index in range(get_child_count()):
		var childNode = get_child(index)
		if childNode.data == data:
			childNode.onMouseLeftButtonPressed()


func selectFirst():
	if get_child_count() > 0:
		get_child(0).onMouseLeftButtonPressed()

	
func createUIHeadIcon(entityData):
	var inst = Global.createSceneInst(Consts.RESOURCE_UI_HEAD_ICON)
	add_child(inst)
	inst.init(entityData)
	return inst


func onSelectEntity(sender, data):
	for index in range(get_child_count()):
		var childNode = get_child(index)
		if sender == childNode:
			childNode.setSelected(true)
		else:
			childNode.setSelected(false)
	
	Inventory.onSelectEntity(sender, data)
